

#include "Socket.hpp"
#include "TcpServer.hpp"
#include "Http.hpp"

int main(int args, char *argv[])
{
    // 检查使用格式
    if (args != 2)
    {
        LOG(INFO, "Usage: %s localport\n", argv[0]);
        exit(0);
    }
    // 获取localport并传递给TcpServer构造
    uint16_t localport = std::stoi(argv[1]);

    HttpServer hserver;
    std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>(
        std::bind(&HttpServer::HanderHttpRequest, &hserver,
                  std::placeholders::_1),
        localport);
    
    tsvr->Start();

    return 0;
}

/*// NetCal cal;

    // IOService io_service(
    //     std::bind(&NetCal::Calculator, &cal,
    //               std::placeholders::_1));

    // // 耦合了io_service和tcpserver
    // std::unique_ptr<TcpServer> utsp = std::make_unique<TcpServer>(
    //     std::bind(&IOService::IOExcute, &io_service,
    //               std::placeholders::_1,
    //               std::placeholders::_2),
    //     localport);

    // utsp->Start();*/